/**
* 文章请求模块
*/
import request from '@/utils/request'

/**
* 获取文章列表
*/
export const getArticles = params => {
  return request({
    method: 'GET',
    url: '/v1_0/articles',
    // params参数用于配置query请求参数
    params
  })
}

/**
* 获取文章详情
*/
export const getArticleInfo = article_id => {
  return request({
    method: 'GET',
    url: `/v1_0/articles/${article_id}`,
  })
}

/**
* 收藏文章
*/
export const addCollect = target => {
  return request({
    method: 'POST',
    url: '/v1_0/article/collections',
    data: {
      target
    }
  })
}

/**
* 取消收藏文章
*/
export const cancelCollect = target => {
  return request({
    method: 'DELETE',
    url: `/v1_0/article/collections/${target}`,
  })
}

/**
* 点赞文章
*/
export const addLike = target => {
  return request({
    method: 'POST',
    url: '/v1_0/article/likings',
    data: {
      target
    }
  })
}

/**
* 取消点赞
*/
export const cancelLike = target => {
  return request({
    method: 'DELETE',
    url: `/v1_0/article/likings/${target}`
  })
}

// export const getArticles = data => {
//   return request({
//     method: 'GET',
//     url: `/v1_0/articles?channel_id=${data.channel_id}&timestamp=${data.timestamp}&with_top=${data.with_top}`,
//   })
// }